package com.qumitech.visualnovel.model.dao.console;

import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import java.text.DecimalFormat;
import com.qumitech.visualnovel.component.util.DateUtil;

public class UserDailyStatisticSumDO {
    private Long id;

    private Date dtdate;

    private Long regUidNum;

    private Long maleRegNum;

    private Long femaleRegNum;

    private Long actUidNum;

    private Long maleLoginNum;

    private Long femaleLoginNum;

    private Long regReaderNum;

    private Long actReaderNum;

    private Long regRemainUidNum1;

    private Long regRemainUidNum3;

    private Long regRemainUidNum7;

    private Long regRemainUidNum14;

    private Long regRemainUidNum30;

    private Long actRemainUidNum1;

    private Long actRemainUidNum3;

    private Long actRemainUidNum7;

    private Long actRemainUidNum14;

    private Long actRemainUidNum30;

    private Long regDevNum;

    private Long actDevNum;

    private Long regRemainDevNum1;

    private Long regRemainDevNum3;

    private Long regRemainDevNum7;

    private Long regRemainDevNum14;

    private Long regRemainDevNum30;

    private Long actRemainDevNum1;

    private Long actRemainDevNum3;

    private Long actRemainDevNum7;

    private Long actRemainDevNum14;

    private Long actRemainDevNum30;

    private Date updatedAt;

    private Date createdAt;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDtdate() {
        return dtdate;
    }

    public void setDtdate(Date dtdate) {
        this.dtdate = dtdate;
    }

    public Long getRegUidNum() {
        return regUidNum;
    }

    public void setRegUidNum(Long regUidNum) {
        this.regUidNum = regUidNum;
    }

    public Long getMaleRegNum() {
        return maleRegNum;
    }

    public void setMaleRegNum(Long maleRegNum) {
        this.maleRegNum = maleRegNum;
    }

    public Long getFemaleRegNum() {
        return femaleRegNum;
    }

    public void setFemaleRegNum(Long femaleRegNum) {
        this.femaleRegNum = femaleRegNum;
    }

    public Long getActUidNum() {
        return actUidNum;
    }

    public void setActUidNum(Long actUidNum) {
        this.actUidNum = actUidNum;
    }

    public Long getMaleLoginNum() {
        return maleLoginNum;
    }

    public void setMaleLoginNum(Long maleLoginNum) {
        this.maleLoginNum = maleLoginNum;
    }

    public Long getFemaleLoginNum() {
        return femaleLoginNum;
    }

    public void setFemaleLoginNum(Long femaleLoginNum) {
        this.femaleLoginNum = femaleLoginNum;
    }

    public Long getRegReaderNum() {
        return regReaderNum;
    }

    public void setRegReaderNum(Long regReaderNum) {
        this.regReaderNum = regReaderNum;
    }

    public Long getActReaderNum() {
        return actReaderNum;
    }

    public void setActReaderNum(Long actReaderNum) {
        this.actReaderNum = actReaderNum;
    }

    public Long getRegRemainUidNum1() {
        return regRemainUidNum1;
    }

    public void setRegRemainUidNum1(Long regRemainUidNum1) {
        this.regRemainUidNum1 = regRemainUidNum1;
    }

    public Long getRegRemainUidNum3() {
        return regRemainUidNum3;
    }

    public void setRegRemainUidNum3(Long regRemainUidNum3) {
        this.regRemainUidNum3 = regRemainUidNum3;
    }

    public Long getRegRemainUidNum7() {
        return regRemainUidNum7;
    }

    public void setRegRemainUidNum7(Long regRemainUidNum7) {
        this.regRemainUidNum7 = regRemainUidNum7;
    }

    public Long getRegRemainUidNum14() {
        return regRemainUidNum14;
    }

    public void setRegRemainUidNum14(Long regRemainUidNum14) {
        this.regRemainUidNum14 = regRemainUidNum14;
    }

    public Long getRegRemainUidNum30() {
        return regRemainUidNum30;
    }

    public void setRegRemainUidNum30(Long regRemainUidNum30) {
        this.regRemainUidNum30 = regRemainUidNum30;
    }

    public Long getActRemainUidNum1() {
        return actRemainUidNum1;
    }

    public void setActRemainUidNum1(Long actRemainUidNum1) {
        this.actRemainUidNum1 = actRemainUidNum1;
    }

    public Long getActRemainUidNum3() {
        return actRemainUidNum3;
    }

    public void setActRemainUidNum3(Long actRemainUidNum3) {
        this.actRemainUidNum3 = actRemainUidNum3;
    }

    public Long getActRemainUidNum7() {
        return actRemainUidNum7;
    }

    public void setActRemainUidNum7(Long actRemainUidNum7) {
        this.actRemainUidNum7 = actRemainUidNum7;
    }

    public Long getActRemainUidNum14() {
        return actRemainUidNum14;
    }

    public void setActRemainUidNum14(Long actRemainUidNum14) {
        this.actRemainUidNum14 = actRemainUidNum14;
    }

    public Long getActRemainUidNum30() {
        return actRemainUidNum30;
    }

    public void setActRemainUidNum30(Long actRemainUidNum30) {
        this.actRemainUidNum30 = actRemainUidNum30;
    }

    public Long getRegDevNum() {
        return regDevNum;
    }

    public void setRegDevNum(Long regDevNum) {
        this.regDevNum = regDevNum;
    }

    public Long getActDevNum() {
        return actDevNum;
    }

    public void setActDevNum(Long actDevNum) {
        this.actDevNum = actDevNum;
    }

    public Long getRegRemainDevNum1() {
        return regRemainDevNum1;
    }

    public void setRegRemainDevNum1(Long regRemainDevNum1) {
        this.regRemainDevNum1 = regRemainDevNum1;
    }

    public Long getRegRemainDevNum3() {
        return regRemainDevNum3;
    }

    public void setRegRemainDevNum3(Long regRemainDevNum3) {
        this.regRemainDevNum3 = regRemainDevNum3;
    }

    public Long getRegRemainDevNum7() {
        return regRemainDevNum7;
    }

    public void setRegRemainDevNum7(Long regRemainDevNum7) {
        this.regRemainDevNum7 = regRemainDevNum7;
    }

    public Long getRegRemainDevNum14() {
        return regRemainDevNum14;
    }

    public void setRegRemainDevNum14(Long regRemainDevNum14) {
        this.regRemainDevNum14 = regRemainDevNum14;
    }

    public Long getRegRemainDevNum30() {
        return regRemainDevNum30;
    }

    public void setRegRemainDevNum30(Long regRemainDevNum30) {
        this.regRemainDevNum30 = regRemainDevNum30;
    }

    public Long getActRemainDevNum1() {
        return actRemainDevNum1;
    }

    public void setActRemainDevNum1(Long actRemainDevNum1) {
        this.actRemainDevNum1 = actRemainDevNum1;
    }

    public Long getActRemainDevNum3() {
        return actRemainDevNum3;
    }

    public void setActRemainDevNum3(Long actRemainDevNum3) {
        this.actRemainDevNum3 = actRemainDevNum3;
    }

    public Long getActRemainDevNum7() {
        return actRemainDevNum7;
    }

    public void setActRemainDevNum7(Long actRemainDevNum7) {
        this.actRemainDevNum7 = actRemainDevNum7;
    }

    public Long getActRemainDevNum14() {
        return actRemainDevNum14;
    }

    public void setActRemainDevNum14(Long actRemainDevNum14) {
        this.actRemainDevNum14 = actRemainDevNum14;
    }

    public Long getActRemainDevNum30() {
        return actRemainDevNum30;
    }

    public void setActRemainDevNum30(Long actRemainDevNum30) {
        this.actRemainDevNum30 = actRemainDevNum30;
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", dtdate=").append(dtdate);
        sb.append(", regUidNum=").append(regUidNum);
        sb.append(", maleRegNum=").append(maleRegNum);
        sb.append(", femaleRegNum=").append(femaleRegNum);
        sb.append(", actUidNum=").append(actUidNum);
        sb.append(", maleLoginNum=").append(maleLoginNum);
        sb.append(", femaleLoginNum=").append(femaleLoginNum);
        sb.append(", regReaderNum=").append(regReaderNum);
        sb.append(", actReaderNum=").append(actReaderNum);
        sb.append(", regRemainUidNum1=").append(regRemainUidNum1);
        sb.append(", regRemainUidNum3=").append(regRemainUidNum3);
        sb.append(", regRemainUidNum7=").append(regRemainUidNum7);
        sb.append(", regRemainUidNum14=").append(regRemainUidNum14);
        sb.append(", regRemainUidNum30=").append(regRemainUidNum30);
        sb.append(", actRemainUidNum1=").append(actRemainUidNum1);
        sb.append(", actRemainUidNum3=").append(actRemainUidNum3);
        sb.append(", actRemainUidNum7=").append(actRemainUidNum7);
        sb.append(", actRemainUidNum14=").append(actRemainUidNum14);
        sb.append(", actRemainUidNum30=").append(actRemainUidNum30);
        sb.append(", regDevNum=").append(regDevNum);
        sb.append(", actDevNum=").append(actDevNum);
        sb.append(", regRemainDevNum1=").append(regRemainDevNum1);
        sb.append(", regRemainDevNum3=").append(regRemainDevNum3);
        sb.append(", regRemainDevNum7=").append(regRemainDevNum7);
        sb.append(", regRemainDevNum14=").append(regRemainDevNum14);
        sb.append(", regRemainDevNum30=").append(regRemainDevNum30);
        sb.append(", actRemainDevNum1=").append(actRemainDevNum1);
        sb.append(", actRemainDevNum3=").append(actRemainDevNum3);
        sb.append(", actRemainDevNum7=").append(actRemainDevNum7);
        sb.append(", actRemainDevNum14=").append(actRemainDevNum14);
        sb.append(", actRemainDevNum30=").append(actRemainDevNum30);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append(", createdAt=").append(createdAt);
        sb.append("]");
        return sb.toString();
    }

    public JSONObject getAccountStatistic(String type) {
        if (type.equals("register")) {
            return getRegisterRecord(regUidNum, maleRegNum, femaleRegNum);
        } else if (type.equals("active")) {
            return getActiveRecord(actUidNum, maleLoginNum, femaleLoginNum);
        } else if (type.equals("registerRemain")) {
            return getRegisterRemainRecord(regUidNum, regRemainUidNum1, regRemainUidNum3, regRemainUidNum7, regRemainUidNum14, regRemainUidNum30);
        } else if (type.equals("activeRemain")) {
            return getActiveRemainRecord(actUidNum, actRemainUidNum1, actRemainUidNum3, actRemainUidNum7, actRemainUidNum14, actRemainUidNum30);
        }
        return new JSONObject();
    }

    public JSONObject getDeviceStatistic(String type) {
        if (type.equals("register")) {
            return getRegisterRecord(regDevNum, null, null);
        } else if (type.equals("active")) {
            return getActiveRecord(actDevNum, null, null);
        } else if (type.equals("registerRemain")) {
            return getRegisterRemainRecord(regDevNum, regRemainDevNum1, regRemainDevNum3, regRemainDevNum7, regRemainDevNum14, regRemainDevNum30);
        } else if (type.equals("activeRemain")) {
            return getActiveRemainRecord(actDevNum, actRemainDevNum1, actRemainDevNum3, actRemainDevNum7, actRemainDevNum14, actRemainDevNum30);
        }
        return new JSONObject();
    }

    private JSONObject getRegisterRecord(Long regNum, Long maleRegNum, Long femaleRegNum) {
        JSONObject record = new JSONObject();
        record.put("gameType", "全部");
        record.put("appVersion", "全部");
        record.put("appName", "全部");
        record.put("appChannel", "全部");
        record.put("targetDate", dtdate);
        record.put("count", regNum);
        record.put("maleCount", maleRegNum);
        record.put("femaleCount", femaleRegNum);
        record.put("regReaderCount", regReaderNum);
        return record;
    }

    private JSONObject getActiveRecord(Long actNum, Long maleActNum, Long femaleActNum) {
        JSONObject record = new JSONObject();
        record.put("gameType", "全部");
        record.put("appVersion", "全部");
        record.put("appName", "全部");
        record.put("appChannel", "全部");
        record.put("targetDate", dtdate);
        record.put("count", actNum);
        record.put("maleCount", maleActNum);
        record.put("femaleCount", femaleActNum);
        record.put("actReaderCount", actReaderNum);
        return record;
    }

    private JSONObject getRegisterRemainRecord(Long regNum, Long remain1, Long remain3, Long remain7, Long remain14, Long remain30) {
        JSONObject record = new JSONObject();
        record.put("appPackage", "全部");
        record.put("appVersion", "全部");
        record.put("appId", "全部");
        record.put("channel", "全部");
        record.put("targetDate", dtdate);
        record.put("activateCount", regNum);
        record.put("nextCount", getRemain(regNum, remain1, 1));
        record.put("threeCount", getRemain(regNum, remain3, 3));
        record.put("sevenCount", getRemain(regNum, remain7, 7));
        record.put("fourteenCount", getRemain(regNum, remain14, 14));
        record.put("thirtyCount", getRemain(regNum, remain30, 30));
        return record;
    }

    private JSONObject getActiveRemainRecord(Long actNum, Long remain1, Long remain3, Long remain7, Long remain14, Long remain30) {
        JSONObject record = new JSONObject();
        record.put("appPackage", "全部");
        record.put("appVersion", "全部");
        record.put("appId", "全部");
        record.put("channel", "全部");
        record.put("targetDate", dtdate);
        record.put("activeCount", actNum);
        record.put("nextCount", getRemain(actNum, remain1, 1));
        record.put("threeCount", getRemain(actNum, remain3, 3));
        record.put("sevenCount", getRemain(actNum, remain7, 7));
        record.put("fourteenCount", getRemain(actNum, remain14, 14));
        record.put("thirtyCount", getRemain(actNum, remain30, 30));
        return record;
    }

    private String getRemain(Long base, Long remain, int ndays) {
        DateUtil dateUtil = new DateUtil();
        Date ndayDate = dateUtil.getDeteBydelta(ndays, dateUtil.dateToStr(dtdate));
        Date nowDate = new Date();
        if (ndayDate.getTime() > nowDate.getTime()) {
            return "-";
        }else {
            DecimalFormat dcmFormat = new DecimalFormat("0.00");
            String remainRate = base>0 ? dcmFormat.format(remain*100.0 / base) : "0.00";
            return String.format("%s%s%d%s", remainRate, "%(", remain, ")");
        }
    }
}